<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <div th:replace="common/common.html"></div>
    <script>
        $(function () {
            $('#tree').treeview({
                data : getTree(),
                showCheckbox : true,
                color: "blue",
                onNodeSelected: function (event,data) {
                    if(data.nodes == undefined){
                        //跳转页面
                        $.addtabs.add({
                            title : data.text,
                            url : data.url,
                            id : data.id
                        })
                    }
                }
            })
        })
        function getTree() {
            //ajax目的:代替刚刚写死的节点内容
            var tree = [];
            $.ajax({
                url : "/menu/getInfo",
                dataType : "json",
                async : false,
                success:function (data) {
                    tree = data;
                },
                error : function (data) {
                    console.log(data);
                    alert("网络异常，请刷新");
                }
            })
            return tree;
        }
    </script>
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-md-3">
            <div id="tree"></div>
        </div>
        <div class="col-md-9">
            <ul class="nav nav-tabs" id="myTab"></ul>
            <div class="tab-content"></div>
        </div>
    </div>
</div>
</body>
</html>